package com.fuershiye.woman.monitor.constants;

import java.util.EnumSet;
import java.util.HashMap;
import java.util.Map;

public enum FileType {
	
	WORD(1, "word", 1),
    EXCEL(2, "excel", 2),
    PDF(3, "pdf", 4),
    ZIP(4, "zip", 8),
    RAR(5, "rar", 16),
    TAR(6, "tar", 32);

    private final Integer code;
    private final String name;
    private final Integer realCode;

    private static final Map<Integer, FileType> lookupByCode=new HashMap<Integer, FileType>();
    private static final Map<Integer, FileType> lookupByRealCode=new HashMap<Integer, FileType>();

    static {
        for(final FileType p: EnumSet.allOf(FileType.class)){
            lookupByCode.put(p.getCode(),p);
            lookupByRealCode.put(p.getRealCode(),p);
        }
    }

    FileType(Integer code, String name, Integer realCode) {
        this.code = code;
        this.name = name;
        this.realCode = realCode;
    }

    public Integer getCode() {
        return code;
    }

    public String getName() {
        return name;
    }

    public Integer getRealCode() {
        return realCode;
    }

    public static FileType getPlatByCode(int code){
        return lookupByCode.get(code);
    }

}
